<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>form</title>
</head>
<body>
    <form>
        <input type="text" name="user" id="user">
        <input type="password" name="pass" id="pass">
        <button type="button" id="login">登录</button>
        <button type="button" id="reg">注册</button>
    </form>
    
    
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script>
        $(function() {

            $('#reg').on('click', function() {
                $.post('/user', {
                    act: 'reg',
                    user: $('#user').val(),
                    pass: $('#pass').val(),
                }).then(res => {
                    console.log(res)
                })
            })

            $('#login').on('click', function() {
                $.post('/user', {
                    act: 'login',
                    user: $('#user').val(),
                    pass: $('#pass').val(),
                }).then(res => {
                    console.log(res)
                })
            })

        })
    </script>
</body>
</html>